package Hash;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Created by wangyg on 2017/9/20.
 */
public class Test {
    public static void main(String[] args) {
        Key key = new Key("1");
        Key key1 = new Key("2");
        Key key2 = new Key("3");
        Map<Key, String> map = new HashMap();
        map.put(key, "1");
        map.put(key1, "2");
        map.put(key2, "3");

        Iterator<Map.Entry<Key, String>> iterator = map.entrySet().iterator();
        for (; true; ) {
            if (iterator.hasNext()) {
                Map.Entry<Key, String> next = iterator.next();
                System.out.println(next.getKey() + ":" + next.getValue());
            } else break;
        }
    }
}
